package model.kwalificatiebeheer;

import java.util.Observable;
import java.util.Observer;

public class Competentie extends Observable implements Comparable<Competentie>{
	/**
	 * Variables
	 */
	private String id;
	private String naam;
	
	/**
	 * Constructors
	 */
	public Competentie(String id, String naam){
		this.id = id;
		this.naam = naam;
	}
	
	/**
	 * Getters and Setters
	 */
	public String getNaam() {
		return naam;
	}
	public void setNaam(String naam) {
		this.naam = naam;
		setChanged();
		notifyObservers();
	}
	public String getId() {
		return id;
	}
	
	public String toString(){
		return " Competentie { id: "+id+" | naam: "+naam+" }";
	}

	/**
	 * @Override
	 * @name: 		compareTo
	 * @description:Compares given Object to this
	 * 				Object. Returns 0 if equals, 
	 * 				returns id if not equals.
	 * @return:		String
	 */
	public int compareTo(Competentie c) {
		return id.compareTo(c.getId());
	}

	/**
	 * @Override
	 * @name: 		equals
	 * @description:Checks if given Object equals
	 * 				this Object
	 * @return:		boolean
	 */
	public boolean equals(Object o) {
		Competentie c = (Competentie) o;
		return id.equals(c.getId());
	}

	/**
	 * @Override
	 * @name: 		hashCode
	 * @description:Returns object unic identifier
	 * @return:		int
	 */
	public int hashCode() {
		return id.hashCode();
	}
	
	/**
	 * @Override
	 * @name: 		delete
	 * @description:deletes competentie
	 * @return:		void
	 */
	public void delete(){
		CompetentieBestand.getInstance().deleteCompetentie(this);
	}
}
